package ioParation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BrowPartaion implements IoParation {
    public void work(BookList bookList) {
        System.out.println("正在借出图书中。。。。。");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借走书本的名字");
        String name = scanner.nextLine();
        int cuurentSized = bookList.getUsedSized();

        //1.判断是否借出
        for (int i = 0; i < cuurentSized; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                if (book.isBorrowed()) {
                    System.out.println("这本书已经被借走了");
                    return;
               }
                book.setBorrowed(true);
                System.out.println("借阅成功");
                return;
            }
            //2.查阅完后没有要找到的书本
            System.out.println("没有你要找的书本");
        }
    }
}
